<?php
defined ( 'BASEPATH' ) or die ( 'forbidden' );
class Showgm_Controller extends Controller {
    private $areaList;    //区号列表
    private $wholeServerHost;    //全局地址

    function _init() {
        $config = get_config();
        $this->wholeServerHost = $config['host_url'];
        $server_list=get_server_list();
        foreach($server_list as $k=>$row) {
            $this->areaList[$row['SvrOutAddr']] = $row['SvrID']."-".$row['SvrName'][1];
        }
    }

    function index() {
        $this->view->display ( "seal/setgm/index" );
    }

    function flexigrid() {
        list ( $colkey, $colsinfo, $where, $sortname, $sortorder, $offset, $rp, $page ) = $this->common->get_flexigrid_params ();

        $sql = "SELECT playerid FROM gm_player WHERE {$where}";
        $this->db->query ( $sql );

        $total=0;
        while ( $n = $this->db->get_array() ) {
            $total = $total + 1;
            $row [] = array (
                    'id' => $total,
                    'cell' => $n 
            );
        }

        $result = array (
                'page' => $page,
                'total' => $total,
                'rows' => $row 
        );
        echo json_encode ( $result );
    }

    function del($id = 0) {
        $c = 0;
        $r = '';
        if ($id === 0) {
            json_output($c, translate('C_INVALID_PARAM_ID'));
        }

        $strResult = 0;

        $sql = "delete from gm_player where playerid = $id";
        if (false == $this->center_connect->execute($sql)) {
            $strResult = $strResult + 1;
        }

        if ($strResult != '0' || $strResult === FALSE) {
            $c = 0;
            $r = translate('C_TIPS_ERROR_TEXT');
        } else {
            $c = 1;
            insert_log(translate('MENU_ACTIVITY_GIFTBAG'),translate('DEL'), array('playerid'=>$id));
            $r = translate('ACTIVITY_GIFTBAG_DEL');
        }
        json_output($c, $r);
    }
    
    function multi() {

    }
}


?>
